<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:xi="http://www.w3.org/2001/XInclude"
      xmlns:py="http://genshi.edgewall.org/">
    <xi:include href="master.html" />

<head />

<body>
    <span>Set for all:</span><br />

    <table border="0">
        <tr>
            <td>Amount</td>
            <td>
                <input id="set_all_amount" />
                <input type="button" value="OK"
                    onclick="setAll('amount_', document.getElementById('set_all_amount').value);" />
            </td>
        </tr>

        <tr>
            <td>Comment</td>
            <td>
                <input id="set_all_comment" />
                <input type="button" value="OK"
                    onclick="setAll('comment_', document.getElementById('set_all_comment').value);" /></td>
        </tr>
    </table>

    <form action="${action}" method="POST">
        <input type="hidden" name="came_from" value="${came_from}" />

        <table>
            <thead>
            <tr>
                <td>Student</td>
                <td>Group</td>
                <td>Amount</td>
                <td>Comment</td>
            </tr>
            </thead>

            <tbody>
                <tr py:for="sig in sigs">
                    <td>${sig.student.title}</td>
                    <td>${sig.group.title}</td>
                    <td><input name="${'amount_%d' % sig.id}" /></td>
                    <td><input name="${'comment_%d' % sig.id}" /></td>
                </tr>
            </tbody>
        </table>

        <?python
          import turbogears
          from mnemoply import model
          registers = model.CashRegister.selectBy(office=turbogears.identity.current.user.office)

          if registers.count():
              user_register = registers[0]
          else:
              user_register = None

          import datetime
          today = datetime.date.today().strftime("%d.%m.%Y")
        ?>
        <p>
        <label class="fieldlabel" for="form_start_date">Выберите месяц</label>
        <input id="form_start_date" type="text" name="start_date" value="${today}" class="calendardatepicker" />
        <input id="form_start_date_trigger" type="button" class="date_field_button" value="Choose" tabindex="9999" />

        <script type="text/javascript">Calendar.setup({
            inputField : "form_start_date",
            ifFormat : "%d.%m.%Y",
            button : "form_start_date_trigger"
        });
        </script>
        </p>
        <p py:if="user_register is None">
            <span>Registers</span>
            <select name='register'>
              <option py:for="r in all_registers" value="${r.id}" py:content="r.name"></option>
            </select>
        </p>
        <p py:if="user_register is not None">
            <input type="hidden" name="register" value="${user_register.id}" />
        </p>

        <input type="submit" value="${_('Enter payment')}" />
    </form>

    <span>${ET(tg.back_widget())}</span>
</body>
</html>
